package down.sallai.ml.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @description: github use interceptor$
 * @author: sallai
 * @time: 2022年1月5日 0005 下午 11:26:25 秒
 */
@Slf4j
public class GithubInterceptor implements HandlerInterceptor {
    @Autowired
    RedisTemplate redisTemplate;

    @Override
    public boolean preHandle(HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Object handler) throws Exception {
        Boolean seesion = (Boolean) request.getSession().getAttribute("github");
        if(null != seesion && seesion) return true;
        log.info("not github verityed");
        request.getRequestDispatcher("/wxapi/verity/page").forward(request,response);
        return false;
    }
}
